package com.qfedu.buy.api.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @program: Boot2008
 * @description:
 * @author: Feri(邢朋辉)
 * @create: 2020-12-31 15:35
 * 标记这是配置
 * 启用Swagger
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    /**
     * 构建文档的基本信息
     */
    public ApiInfo createApi(){
        return new ApiInfoBuilder().description("邻里购项目的认证接口文档")
                .title("邻里购项目接口文档").contact(new Contact("Feri","http://www.qfedu.com","xingfei_work@163.com"))
                .version("1.0").build();
    }

    /**
     * 就是ioc创建实例 修饰方法 方法必须返回对象
     */
    @Bean
    public Docket createDocket(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(createApi())
                .select().apis(RequestHandlerSelectors.basePackage("com.qfedu.buy.api.api")).build();
    }
}